package dbv;

import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import com.swtdesigner.SWTResourceManager;

public class Prueba {
	protected Shell shell;
	private Text nomText;
	private Text apeText;
	private Label Nombre;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		Display display = Display.getDefault();
		Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
			public void run() {
				try {
					Prueba window = new Prueba();
					window.open();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setSize(476, 365);
		shell.setText("SWT Application");
		shell.setLayout(new FormLayout());
		
		Composite composite = new Composite(shell, SWT.NONE);
		composite.setFont(SWTResourceManager.getFont("Calibri", 11, SWT.BOLD));
		GridLayout gl_composite = new GridLayout(2, false);
		composite.setLayout(gl_composite);
		FormData fd_composite = new FormData();
		fd_composite.top = new FormAttachment(0, 10);
		fd_composite.left = new FormAttachment(0, 10);
		composite.setLayoutData(fd_composite);
		
		Composite composite_1 = new Composite(shell, SWT.NONE);
		fd_composite.right = new FormAttachment(composite_1, 0, SWT.RIGHT);
		fd_composite.bottom = new FormAttachment(composite_1, -6);
		FormData fd_composite_1 = new FormData();
		fd_composite_1.bottom = new FormAttachment(100, -10);
		fd_composite_1.top = new FormAttachment(0, 221);
		fd_composite_1.left = new FormAttachment(0, 10);
		fd_composite_1.right = new FormAttachment(100, -10);
		
		Nombre = new Label(composite, SWT.WRAP);
		Nombre.setFont(SWTResourceManager.getFont("Calibri", 11, SWT.BOLD));
		Nombre.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		Nombre.setText("Nombre");
		
		nomText = new Text(composite, SWT.BORDER);
		nomText.setFont(SWTResourceManager.getFont("Calibri", 11, SWT.BOLD));
		GridData gd_nomText = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
		gd_nomText.widthHint = 100;
		nomText.setLayoutData(gd_nomText);
		
		Label lblApellido = new Label(composite, SWT.WRAP);
		lblApellido.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
		lblApellido.setText("Apellido");
		lblApellido.setFont(SWTResourceManager.getFont("Calibri", 11, SWT.BOLD));
		
		apeText = new Text(composite, SWT.BORDER);
		apeText.setFont(SWTResourceManager.getFont("Calibri", 11, SWT.BOLD));
		apeText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
		composite_1.setLayoutData(fd_composite_1);
		initDataBindings();

	}
	protected DataBindingContext initDataBindings() {
		DataBindingContext bindingContext = new DataBindingContext();
		//
		return bindingContext;
	}
}
